/****************************************************
          File Name:msgget.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Thu 11 Sep 2014 10:02:17 AM CST
*****************************************************/

#include"msg.h"
#include<fcntl.h>

int main(int argc, char *argv[])
{
    key_t key;
    int status;
    int perm=S_IRUSR|S_IWUSR|S_IWGRP;

    key=ftok(PATH,309); //pisces
    printf("the key : 0x%x\n",key);
    status=msgget(key,perm|IPC_CREAT|IPC_EXCL);
    if(status==-1 && errno != EEXIST)
        err("msgget");
    printf("the message id: %d\n",status);
    return 0;
}
